﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DateiaftenLibTest;

/// <summary>
/// Summary description for InterestBLL
/// </summary>
public class InterestBLL
{
    private static InterestBLL instance;
    private DateiaftenDataContext db;

    public InterestBLL()
    {
        db = new DateiaftenDataContext();
    }

    public static InterestBLL Instance
    {
        get
        {
            if (instance == null)
            {
                instance = new InterestBLL();
            }
            return instance;
        }
    }

    public IQueryable findInterestsByUsername(string username)
    {
        try
        {
            var interests = from i in db.Interests
                            from ui in db.InterestUserNames
                            where i.InterestId == ui.InterestId
                            where ui.UserName == username
                            select new { InterestName = i.InterestName };
            return interests;
        }
        catch
        {
            return null;
        }
    }
}